package com.lepu.app.fun.index.bean;

import java.util.ArrayList;

import org.json.JSONException;
import org.json.JSONObject;

import com.app.utils.Setting;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.lepu.app.fun.knowledge.bean.Article;
import com.lepu.app.fun.my.bean.BeanPubContent;

public class BeanIndex {

	public ArrayList<Article> BannerList; // 顶部轮播图banner
	public ArrayList<Article> AuthorList; // 作家专栏banner
	public ArrayList<Article> SeriesList; // 系列文章
	public ArrayList<Article> DayArticleList; // 每日关注文章
	public ArrayList<BeanPubContent> HotTopicList; // 今日热帖
	
	public static BeanIndex parseJsonData(String dataString) {
		String result = "";
		try {
			JSONObject jsonObject = new JSONObject(dataString);
			JSONObject obj1 = (JSONObject) jsonObject.get("Result");
			JSONObject obj2 = (JSONObject) obj1.get("DetailInfo");

			result = obj2.toString();
		} catch (JSONException e) {
			e.printStackTrace();
		}

		Gson gson = new Gson();
		BeanIndex beanIndex = gson.fromJson(result, new TypeToken<BeanIndex>() {
		}.getType());
		return beanIndex;
	}

	public static BeanIndex getTestData() {
		BeanIndex beanIndex = new BeanIndex();

		ArrayList<Article> BannerList = new ArrayList<Article>();// 顶部轮播图
		ArrayList<Article> AuthorList = new ArrayList<Article>(); // 作家专栏banner
		ArrayList<Article> SeriesList = new ArrayList<Article>(); // 系列文章
		ArrayList<Article> DayArticleList = new ArrayList<Article>();// 每日关注文章
		ArrayList<BeanPubContent> HotTopicList = new ArrayList<BeanPubContent>(); // 今日热帖

		for (int i = 0; i < 3; i++) {
			Article item = new Article();
			BannerList.add(item);
		}

		for (int i = 0; i < 3; i++) {
			Article item = new Article();
			AuthorList.add(item);
		}

		for (int i = 0; i < 3; i++) {
			Article item = new Article();
			item.LinkURL = Setting.getTestUrl(1);
			SeriesList.add(item);
		}

		for (int i = 0; i < 5; i++) {
			Article item = new Article();
			item.LinkURL = Setting.getTestUrl(1);
			DayArticleList.add(item);
		}

		for (int i = 0; i < Setting.PAGE_SIZE; i++) {
			HotTopicList.add(new BeanPubContent());
		}

		beanIndex.BannerList = BannerList;
		beanIndex.AuthorList = AuthorList;
		beanIndex.SeriesList = SeriesList;
		beanIndex.DayArticleList = DayArticleList;
		beanIndex.HotTopicList = HotTopicList;

		return beanIndex;

	}

}
